package com.example.zz.example.pattern.strategy;

/**
 * @author: zhuozhang6
 * @date: 2021/11/7
 * @email: zhuozhang6@iflytek.com
 * @Description:
 *
 * 参考：https://www.runoob.com/design-pattern/strategy-pattern.html
 */
public class Test {
    public static void main(String[] args) {

        Context context = new Context(new OperationAdd());
        int i = context.executeStrategy(1, 2);
        Context context2 = new Context(new OperationSubtract());
        int i1 = context2.executeStrategy(1, 2);
        Context context3 = new Context(new OperationMultiply());
        int i2 = context3.executeStrategy(1, 2);

        System.out.println("add = " + i + " subtract = " + i1 + " multiply = " + i2);

    }
}
